﻿using GameFramework.DataTable;
using GameFramework;
namespace MYSTARFORCE {
    /// <summary>
    /// 武器Data
    /// </summary>
    public class WeaponData : AccessoryObjectData
    {
        /// <summary>
        /// 攻击力
        /// </summary>
        public int Attack
        {
            get
            {
                return m_Attack;
            }
        }
        private int m_Attack = 0;


        /// <summary>
        /// 攻击间隔
        /// </summary>
        public float AttackInterval
        {
            get
            {
                return m_AttackInterval;
            }
        }
        private float m_AttackInterval = 0f;

        /// <summary>
        /// 子弹类型ID
        /// </summary>
        public int BulletId
        {
            get
            {
                return m_BulletId;
            }
        }
        private int m_BulletId = 0;

        /// <summary>
        /// 子弹速度
        /// </summary>
        public float BulletSpeed
        {
            get
            {
                return m_BulletSpeed;
            }
        }
        private float m_BulletSpeed = 0f;

        /// <summary>
        /// 子弹音效
        /// </summary>
        public int BulletSoundId
        {
            get
            {
                return m_BulletSoundId;
            }
        }
        private int m_BulletSoundId = 0;


        public WeaponData(int entityId, int typeId, int ownerId, CampType ownerCamp) : base(entityId, typeId, ownerId, ownerCamp)
        {
            // 从weapon表中读取对应的数据
            IDataTable<DRWeapon> dtWeapon = GameEntry.DataTable.GetDataTable<DRWeapon>();
            DRWeapon dRWeapon = dtWeapon.GetDataRow(TypeId);

            if (dRWeapon == null)
            {
                return;
            }

            m_Attack = dRWeapon.Attack;
            m_AttackInterval = dRWeapon.AttackInterval;
            m_BulletId = dRWeapon.BulletId;
            m_BulletSpeed = dRWeapon.BulletSpeed;
            m_BulletSoundId = dRWeapon.BulletSoundId;
        }
    }
}